<!DOCTYPE html>
<html lang="en">
<head>
	<title>TikTok Followers Count Leaderboard ${year} | GugeeData</title>
	<meta name="viewport"
	      content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="keywords" content="Tiktok Followers growth,TikTok Follower Count, TikTok Trends, Creator of TikTok, TikTok Realtime, TikTok Famous, Tiktok Analytics, TikTok Followers Comparison">
	<meta name="description" content="This is the TikTok follower growth count leaderboard for ${year}.">
	<meta property="og:title" content="TikTok Followers Count Leaderboard ${year} | GugeeData">
	<meta property="og:description" content="This is the TikTok follower growth count leaderboard for ${year}.">
	<meta property="og:type" content="website">
	<meta property="og:url" content="${request.contextPath}/ranking/follower">
	<meta property="og:image" content=" https://seo-imags.s3.us-east-2.amazonaws.com/Logo.png">
	<meta property="og:description" content="This is the TikTok ranking list for ${year}.">
	<meta name="twitter:title" content="TikTok Followers Count Leaderboard ${year} | GugeeData">
	<meta name="twitter:description" content="This is the TikTok follower growth count leaderboard for ${year}.">
	<link rel="icon" href="${request.contextPath}/static/img/favicon.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="${request.contextPath}/static/img/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" href="${request.contextPath}/static/css/reset.css">
    <#if isMobile == false>
	    <link rel="stylesheet" href="${request.contextPath}/static/css/common.css">
	    <link rel="stylesheet" href="${request.contextPath}/static/plugins/layui/layui.css">
		<link rel="stylesheet" href="${request.contextPath}/static/css/rank.css">
    <#else>
	    <link rel="stylesheet" href="${request.contextPath}/static/css/mobile/common.css">
	    <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@500&display=swap" rel="stylesheet">
		<link rel="stylesheet" href="${request.contextPath}/static/css/mobile/rank.css">
    </#if>
    <#include "../component/facebookPixel.ftl">
</head>
<body>
<#include "../header_new.ftl">
<#if isMobile == false>
	<main>
		<section>
			<div class="wrapper wrap-video">
				<h1>${title}</h1>
				<h3>${subTitle}</h3>
				<div class="main-content">
					<div class="rank-type">
						<div class="left">
							<ul>
								<li data-id="1" class="is-active" onclick="selectOption(this, 0)">Daily</li>
								<li data-id="2" onclick="selectOption(this, 0)">Weekly</li>
								<li data-id="3" onclick="selectOption(this, 0)">Monthly</li>
							</ul>
							<div class="date" onmouseover="showPopDate()" onmouseout="hidePopDate()">
								<div>
									<span class="label"></span>
									<i class="iconfont iconDate"></i>
								</div>
								<div class="pop-date" >
									<ul id="dateList"></ul>
								</div>
							</div>
                            <#if login == false || (roleId lt 3)>
	                            <div class="btn-export" onmouseover="showLock(this)" onmouseout="hideLock(this)">
		                            <button class="gd-btn btn-info">Export</button>
		                            <div class="lock">
			                            <i class="iconfont iconsuoding"></i>
		                            </div>
	                            </div>
                            <#else>
	                            <div class="btn-export">
		                            <button class="gd-btn btn-info" onclick="exportRank()">Export</button>
	                            </div>
                            </#if>

						</div>
						<div class="right">
                            <#setting datetime_format="MM-dd-yyyy HH:mm"/>
							Data Updated： ${(updateTime*1000)?number_to_datetime} UTC
						</div>
					</div>
					<div class="blogger-type">
						<div class="left">Categories :</div>
						<div class="right">
							<ul id="bloggerTypeList"></ul>
						</div>
					</div>
					<div id="rankTable" style="position: relative;border: 1px solid #DCDFE6;border-radius: 8px;margin-top: 8px;">
						<table class="tb-main">
							<thead>
							<tr>
								<th class="th-gd">Rank</th>
								<th align="left">TikToker</th>
								<th >GD Score</th>
								<th>Followers</th>
								<th>Follower Growth</th>
								<th>Action</th>
							</tr>
							</thead>
							<tbody id="scrollList">
                            <#list dataList.list as data>
								<tr>
									<td>
										<div class="td-inx">
											<div class="rank-default">
                                                <#if data.ranking lt 10>
													0${data.ranking}
                                                <#else>
                                                    ${data.ranking}
                                                </#if>
											</div>
                                            <#if data.state == 'UP'>
												<div class="sub-rank rank-up">↑ ${data.position}</div>
                                            <#elseif data.state == 'NEW'>
												<div class="sub-rank rank-new">NEW</div>
                                            <#elseif data.state == 'FLAT'>
												<div class="sub-rank rank-flat">-</div>
                                            <#else>
												<div class="sub-rank rank-down">↓ ${data.position?abs}</div>
                                            </#if>
										</div>
									</td>
									<td class="tb-tiktoker">
										<div class="avatar">
											<img src='${data.avatar}' alt="${data.nickname}"/>
                                            <#if (data.enterpriseVerifyReason?? && data.enterpriseVerifyReason != '') || (data.customVerify?? && data.customVerify != '')>
												<i class="iconfont iconzhichi"></i>
                                            </#if>
										</div>
										<div>
											<div class="tb-name">
                                                ${data.nickname}
												<svg title="${data.region}" class="icon icon-country" aria-hidden="true">
													<use xlink:href="#icon_${data.region}"></use>
												</svg>
                                                <#if data.withFusionShopEntry == true>
													<img src="${request.contextPath}/static/img/E-commerce.png" alt="shop">
                                                </#if>
                                                <#if data.bioEmail??>
													<a href="mailto:${data.bioEmail}">
														<img src="${request.contextPath}/static/img/mail.png" alt="mail">
													</a>
                                                </#if>
											</div>
											<div class="bottom">
                                                ${data.uniqueId!''}
											</div>
										</div>
									</td>
									<td>
                                        <#assign score=myController.getNumber(data.score)>
                                        ${score}
									</td>
									<td>
                                        <#assign follower=myController.getNumber(data.follower)>
                                        ${follower}
									</td>
									<td>
                                        <#assign followerGrowth=myController.getNumber(data.followerGrowth)>
                                        ${followerGrowth}
									</td>
									<td>
										<div class="td-action">
                                            <#if login == false>
												<a href="javascript:;" onclick="toLogin()">
													<div class="blue">
														<i class="iconfont iconxiangqing"></i>
													</div>
												</a>
                                            <#else>
												<a href="${contextPath}/tiktoker/${data.uniqueId}">
													<div class="blue">
														<i class="iconfont iconxiangqing"></i>
													</div>
												</a>
                                            </#if>
										</div>
									</td>
								</tr>
                            </#list>
							</tbody>
							<!-- tbody end -->
							<tfoot>
							<tr>
								<td colspan="8">
                                    <#if login == false>
										<a href="javascript:;" onclick="toLogin()">
											<span>View More</span>
										</a>
                                    <#else>
										<div class="permission-tips" id="">
                                            <#if dataList.list?size lt 10>
												You've reached the end.
                                            <#else>
												<div class="pagination" id="pagination"></div>
                                            </#if>
										</div>
                                    </#if>
								</td>
							</tr>
							</tfoot>
						</table>
					</div>
				</div>
			</div>
		</section>
	</main>
    <#include "../footer.ftl">
	<script src="${request.contextPath}/static/plugins/layui/layui.js" charset="utf-8"></script>
	<script src="${request.contextPath}/static/js/nums.js" charset="utf-8"></script>
	<script>
        init()
        function init() {
            initPagination()
            getTime()
            getBloggerType()
        }
        let listTotal = ${dataList.totalCount?c}
        function initPagination() {
            layui.use('laypage', function () {
                let laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'pagination', //注意，这里的 test1 是 ID，不用加 # 号
                    count: listTotal, //数据总数，从服务端得到
                    prev: '<i class="iconfont iconicon_previous"></i>',
                    next: '<i class="iconfont iconarrowright"></i>',
                    jump: (obj, first) => {
                        if (!first) {
                            page = obj.curr
                            getRankingList()
                        }
                    }
                })
            })
        }
        let dailyDateList = []
        let monthlyDateList = []
        let weeklyDateList = []
        let curDate = {}
        function getTime() {
            _axios.get('/v1/ranking/date').then( res => {
                if (res && res.Code === 200) {
                    dailyDateList = res.Data.dailyDate
                    monthlyDateList = res.Data.monthlyDate
                    weeklyDateList = res.Data.weeklyDate
                    let str = ''
                    dailyDateList.forEach((item,index) => {
                        str += '<li data-desc="' + item.dateDesc + '" data-code="' + item.dateCode + '" onclick="selectOption(this, 1)" class="mask-item'
                        if(index === 0) {
                            str += ' is-active'
                            document.querySelector('.rank-type .date .label').innerText = item.dateDesc
                            curDate = item
                        }
                        str += '">' +
                            item.dateDesc +
                            '</li>'
                    })
	                document.getElementById('dateList').innerHTML = str
                }
            })
        }
        let bloggerType = {id: 0, name: 'All'}
        function getBloggerType() {
            _axios.get('/v1/blogger/type').then(res => {
                if (res && res.Code === 200) {
                    let str = ''
                    str += '<li data-id="0" data-name="All" class="mask-item is-active" onclick="selectOption(this, 2)">'
                    str += 'All' +
                        '</li>'
                    res.Data.forEach((item, index) => {
                        str += '<li data-id="' + item.id + '" data-name="' + item.name + '" onclick="selectOption(this, 2)" class="mask-item"'
                        str += '>' +
                            item.name +
                            '</li>'
                    })
					document.getElementById('bloggerTypeList').innerHTML = str
                }
            })
        }
        let rankingType = 1
        function showLock(e) {
            e.querySelector('.lock').show('flex')
        }
        function hideLock(e) {
            e.querySelector('.lock').hide()
        }
        let popDate = document.querySelector('.pop-date')
        let isChangeOption = false
        function selectOption (e, inx) {
            <#if login == false>
                toLogin()
                return false
            </#if>
            if(inx === 0) {
                rankingType = e.getAttribute('data-id')
                let arr = []
                let str = ''
                let dateList = []
                if(rankingType === '1') {
                    curDate = dailyDateList[0]
                    dateList = dailyDateList
                } else if(rankingType === '2') {
                    curDate = weeklyDateList[0]
                    dateList = weeklyDateList
                } else {
                    curDate = monthlyDateList[0]
                    dateList = monthlyDateList
                }

                document.querySelector('.rank-type .left>ul .is-active').classList.remove('is-active')
                dateList.forEach((item,index) => {
                    str += '<li data-desc="' + item.dateDesc + '" data-code="' + item.dateCode + '" onclick="selectOption(this, 1)" class="mask-item'
                    if(index === 0) {
                        str += ' is-active'
                        curDate = item
	                    document.querySelector('.rank-type .left .date .label').innerText = item.dateDesc
                    }
                    str += '">' +
                        item.dateDesc +
                        '</li>'
                })
	            document.getElementById('dateList').innerHTML = str
            } else if(inx === 1) {
                curDate = {
                    dateCode: e.getAttribute('data-code'),
                    dateDesc: e.getAttribute('data-desc')
                }
                document.querySelector('.rank-type .left .date .label').innerText = e.getAttribute('data-desc')
                popDate.hide()
            } else {
                document.querySelector('#bloggerTypeList .is-active').classList.remove('is-active')
                bloggerType = {
                    id: e.getAttribute('data-id'),
                    name: e.getAttribute('data-name')
                }
            }
            e.classList.add('is-active')
            page = 1
            isChangeOption = true
            getRankingList()
        }
        let page = 1
        function showPopDate() {
            popDate.show()
        }
        function hidePopDate() {
            popDate.hide()
        }
        function getRankingList() {
            document.getElementById('rankTable').showLoading()
	        let data = {
                rankingType: rankingType,
                date: curDate.dateCode,
                bloggerTypeId: bloggerType.id,
                pageSize: 10,
                page: page
            }
	        _axios.get(getEncodeUrl('/v1/ranking/follower', data)).then(res => {
                if (res.Code === 200) {
                    let str = ''
                    res.Data.ItemList.forEach(item => {
                        str += '<tr>' +
                            '<td>' +
                            '<div class="td-inx">' +
                            '<div class="rank-default">'
                        if(item.ranking < 10) {
                            str += '0' + item.ranking
                        } else {
                            str += item.ranking
                        }
                        str += '</div>'
                        if(item.state === 'UP') {
                            str +=  '<div class="sub-rank rank-up">↑ ' + item.position + '</div>'
                        } else if(item.state === 'NEW') {
                            str += '<div class="sub-rank rank-new">NEW</div>'
                        } else if(item.state === 'FLAT') {
                            str += '<div class="sub-rank rank-flat">-</div>'
                        } else {
                            str += '<div class="sub-rank rank-down">↓ ' + Math.abs(+item.position) + '</div>'
                        }
                        str += '</div>' +
                            '</td>' +
                            '<td class="tb-tiktoker">' +
                            '<div class="avatar">' +
                            '<img src="' + item.avatar + '" alt="' + item.nickname + '"/>'
                        if(item.enterpriseVerifyReason || item.customVerify) {
                            str += '<i class="iconfont iconzhichi"></i>'
                        }
                        str += '</div>' +
                            '<div>' +
                            '<div class="tb-name">' + item.nickname +
                            '<svg title="' + item.region + '" class="icon icon-country" aria-hidden="true">' +
                            '<use xlink:href="#icon_' + item.region + '"></use>' +
                            '</svg>'
                        if(item.withFusionShopEntry) {
                            str += '<img src="${request.contextPath}/static/img/E-commerce.png" alt="shop">'
                        }
                        if(item.bioEmail) {
                            str += '<a href="mailto:' + item.bioEmail + '">' +
                                '<img src="${request.contextPath}/static/img/mail.png" alt="mail">' +
                                '</a>'
                        }
                        str += '</div>' +
                            '<div class="bottom">' + item.uniqueId +
                            '</div>' +
                            '</div>' +
                            '</td>' +
                            '<td>' + numFormat(+item.score) + '</td>' +
                            '<td>' + numFormat(item.follower) +
                            '</td>' +
                            '<td>' + numFormat(item.followerGrowth) +
                            '</td>' +
                            '<td>' +
                            '<div class="td-action">' +
                            <#if login == false>
                            '<a href="javascript:;" onclick="toLogin()">' +
                            '<div class="blue">' +
                            '<i class="iconfont iconxiangqing"></i>' +
                            '</div>' +
                            '</a>' +
                            <#else>
                            '<a href="${contextPath}/tiktoker/' + item.uniqueId + '">' +
                            '<div class="blue">' +
                            '<i class="iconfont iconxiangqing"></i>' +
                            '</div>' +
                            '</a>' +
                            </#if>
                            '</div>' +
                            '</td>' +
                            '</tr>'
                    })
                    if(!document.getElementById('pagination')){
                        document.querySelector('.permission-tips').innerHTML = '<div class="pagination" id="pagination"></div>'
                    }
                    if(isChangeOption) {
                        listTotal = +res.Data.TotalCount
                        initPagination()
	                    isChangeOption = false
                    }
					document.getElementById('scrollList').innerHTML = str
                }
                document.getElementById('rankTable').hideLoading()
	        })
        }
        function exportRank() {
            let data = {
                rankingType: rankingType,
                date: curDate.dateCode,
                bloggerTypeId: bloggerType.id,
            }
            let url = getEncodeUrl('${contextPath}/v1/ranking/follower/export', data)
	        window.open(url)
        }
	</script>
<#else>
	<#include './mobile/follower.ftl'>
</#if>
</body>
</html>
